//
//  SimulationMainVC.m
//  ATAInterview
//
//  Created by up72-17 on 2018/12/10.
//  Copyright © 2018 up72-17. All rights reserved.
//

#import "SimulationMainVC.h"

@interface SimulationMainVC ()

@end

@implementation SimulationMainVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [myScrollView setPagingEnabled:YES];
    
    [myScrollView setContentSize:CGSizeMake(6 * SCREEN_WIDTH, 0)];
    
    
    [MTool setViewRadius:9 view:page_1];
    [MTool setViewRadius:9 view:page_2];
    [MTool setViewRadius:9 view:page_3];
    [MTool setViewRadius:9 view:page_4];
    [MTool setViewRadius:9 view:page_5];
    [MTool setViewRadius:9 view:page_6];
    [MTool setViewRadius:9 view:pageBackView];
    
    
    [myPageControl setNumberOfPages:6];
    
    for (NSInteger i = 0; i < 6; i++) {
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(i * SCREEN_WIDTH, -NAVIGATION_HEIGHT / 2, SCREEN_WIDTH, SCREEN_HEIGHT)];
//        [imageView setContentMode:UIViewContentModeScaleAspectFit];
        
        if (kiPhone5) {
            [imageView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"640x1136_%ld", (long)(i + 1)]]];
        } else if (kiPhone6) {
            [imageView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"750x1334_%ld", (long)(i + 1)]]];
        } else if (kiPhone6Plus) {
            [imageView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"1224x2208_%ld", (long)(i + 1)]]];
        } else if (IS_IPHONE_X_S) {
            [imageView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"1125x2436_%ld", (long)(i + 1)]]];
        } else {
            [imageView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"640x960_%ld", (long)(i + 1)]]];
        }
        
        
        [myScrollView addSubview:imageView];
    }
    
    
}

- (IBAction)backButtonAction:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma 实现协议UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    NSInteger page = scrollView.contentOffset.x / SCREEN_WIDTH;
    
    [page_1 setTextColor:[UIColor darkGrayColor]];
    [page_2 setTextColor:[UIColor darkGrayColor]];
    [page_3 setTextColor:[UIColor darkGrayColor]];
    [page_4 setTextColor:[UIColor darkGrayColor]];
    [page_5 setTextColor:[UIColor darkGrayColor]];
    [page_6 setTextColor:[UIColor darkGrayColor]];
    
    [page_1 setBackgroundColor:[UIColor clearColor]];
    [page_2 setBackgroundColor:[UIColor clearColor]];
    [page_3 setBackgroundColor:[UIColor clearColor]];
    [page_4 setBackgroundColor:[UIColor clearColor]];
    [page_5 setBackgroundColor:[UIColor clearColor]];
    [page_6 setBackgroundColor:[UIColor clearColor]];
    
    
    if(page != myPageControl.currentPage) {
        myPageControl.currentPage = page;
    };
    if (page == 0)[page_1 setTextColor:kColorWithRGB(0x00D985)];
    if (page == 1)[page_2 setTextColor:kColorWithRGB(0x00D985)];
    if (page == 2)[page_3 setTextColor:kColorWithRGB(0x00D985)];
    if (page == 3)[page_4 setTextColor:kColorWithRGB(0x00D985)];
    if (page == 4)[page_5 setTextColor:kColorWithRGB(0x00D985)];
    if (page == 5)[page_6 setTextColor:kColorWithRGB(0x00D985)];
    
    if (page == 0)[page_1 setBackgroundColor:[UIColor whiteColor]];
    if (page == 1)[page_2 setBackgroundColor:[UIColor whiteColor]];
    if (page == 2)[page_3 setBackgroundColor:[UIColor whiteColor]];
    if (page == 3)[page_4 setBackgroundColor:[UIColor whiteColor]];
    if (page == 4)[page_5 setBackgroundColor:[UIColor whiteColor]];
    if (page == 5)[page_6 setBackgroundColor:[UIColor whiteColor]];
    
    if (page == 5) {
        [startButton setHidden:NO];
    } else {
        [startButton setHidden:YES];
    }
}



- (IBAction)buttonAction:(id)sender {
    [[GlobalData sharedGlobalData] setQuestionIndex:0];
    AudioQuestionsVC *audioQuestions = [[AudioQuestionsVC alloc] init];
    [self.navigationController pushViewController:audioQuestions animated:YES];
    
//    VideoQuestionsVC *videoQuestions = [[VideoQuestionsVC alloc] init];
//    [self.navigationController pushViewController:videoQuestions animated:YES];
    
}





@end
